home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
GameKit
/
Examples
/
PacMan
/
Monster.h
< prev
next >
Wrap
Text File
|
1995-06-12
|
2KB
|
68 lines
// This object moves and renders the Ghosts that chase and kill you.
#import <gamekit/gamekit.h>
typedef int intm[8]; // used in the arrays to control movement of ghosts
// valid states for a ghost
#define HOVER 0
#define CHASE 1
#define RUN 2
#define HOME 3
#define HARMLESS 2 // return value for munch (YES/NO/HARMLESS)
// ghost colors (for "myColor" instance variable)
#define BLUE_GHOST 0
#define GREEN_GHOST 1
#define ORANGE_GHOST 2
#define PURPLE_GHOST 3
#define INVISIBLE_GHOST 4
#define GHOST_EYES 5
// power dot states
#define DOT_NONE 0
#define DOT_EATEN 1
#define DOT_FADING 2
@interface Monster:GameActor
{
id player; // This is who we chase
id maze; // This is where we are
id ghosts[3]; // The tiff of the ghost images
BOOL eatable; // Can we be eaten ??
int lastSense; // Previous value of "sense"
int powerState; // what's the power dot state
int powerTime; // how long power dot's been on
int state; // what we're doing
int fix; // fix flag for hovering movement
int loops; // number of times we've circled around in the ghost box
int img; // which animation frame to use
int myColor; // which ghost (0-3) am I?
}
- init; // Calls method below with semi-sane values...but you should use below:
- initGhost:(int)num player:(id)pac maze:(id)world at:(int)sx :(int)sy;
// designated initializer; initializes all the ghosts.
- renderAt:(int)posx :(int)posy move:(BOOL)moveOk; // draw ghost...
// lockfocus in the view where it's drawn first.
- move:sender; // decide where to move the ghost for the next frame
- powerDot:(BOOL)eat; // called when power dots are eaten or run out.
- (BOOL)canBeEaten; // returns "eatable".
- (int)munch; // called when pac intersects ghost
// These four methods handle actual movement. They are internal, and generally
// called by the (-move:) method. You shouldn't ever use them directly!
- hover; // hover moves solid ghost when in ghost chamber
- runAway; // ghost runs away at 1/2 speed after power pill
- chase; // ghost chases player down
- goHome; // used to make the eyes run to ghost chamber at 2x speed
- moveOneFrame; // makes the animation advance one step.
- powerCount; // power dot count down
@end